/*
 * Copyright 2011 Kim Lindhardt Madsen
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package dk.lindhardt.gwt.geie.shared;

import com.google.gwt.user.client.ui.Widget;

import java.io.Serializable;

/**
 * User: AnAmuser
 * Date: 07-06-11
 * <p/>
 * Cell interface
 */
public interface Cell<T extends Serializable> extends Serializable {

   /**
    * @return value of this cell
    */
   T getValue();

   /**
    * @param value sets the value of this cell
    */
   void setValue(T value);

   /**
    * @return position information of this cell
    */
   Position getPosition();

   /**
    * @param position sets the position of this cell
    */
   void setPosition(Position position);

   /**
    * @return the key for the formatter of this cell
    */
   CellFormatKey getCellFormatKey();

   /**
    * @param cellFormatKey sets the key for the formatter to use on this cell
    */
   void setCellFormatKey(CellFormatKey cellFormatKey);

   /**
    * @return a link if the cell is a hyperlink
    */
   Link getLink();

   /**
    * @param  link sets link if the cell is a hyperlink
    */
   void setLink(Link link);

   /**
    * @return gets whether this cell is locked. That is whether the client will be able to edit the content of this cell
    */
   boolean isLocked();

   /**
    * @param locked sets whether this cell is locked. That is whether the client will be able to edit the content of this cell
    */
   void setLocked(boolean locked);

   /**
    * @see #setDirty(boolean)
    * @return is content of the cell dirty.
    */
   boolean isDirty();

   /**
    * The dirty property represents whether changes of the content of this cell has been presented to the user yet.
    * @param dirty is content of the cell dirty.
    */
   void setDirty(boolean dirty);

   /**
    * Returns cell value as a widget.
    * @param format the format used on the cell
    * @return widget representation of the cell value
    */
   Widget toWidget(CellFormat format);

   /**
    * @return copies this cell to a new instance
    */
   Cell copy();
}
